package chapter9.javaFile.NIO;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

public class TestPath {

	public static void main(String[] args) {

		Path path1 = Paths.get("dataOutputInputfile.txt");
		System.out.println(path1.toAbsolutePath());
		Path path2 = path1.resolveSibling("ficheroMAC.txt");
		System.out.println("path.getRoot: " + path2.getRoot());
		System.out.println("path.getParent: " + path2.getParent());
		FileReader fr = null;
		try {
			fr = new FileReader(path2.toFile());
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		BufferedReader bf = new BufferedReader(fr);

		String linea;
		try {
			while ((linea = bf.readLine()) != null) {
				System.out.println(linea);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			bf.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
